import type { ApiRequestConfig, ApiResponseSuccess } from 'axios';

export interface BaseQuery {
  page?: number;
  page_size?: number;
  map?: string;
  [key: string]: any;
}

export interface ApiFuncData<D = any, Q = Record<keyof any, any>>
  extends Omit<ApiRequestConfig<D>, 'query' | 'method' | 'url'> {
  query?: Q;
  url?: ApiRequestConfig['url'];
  method?: ApiRequestConfig['method'];
}
// Pick<
//   AxiosRequestConfig<D>,
//   'params' | 'data' | 'query' | 'method' | 'cache' | 'toastError'
// >;

export type RequestFunction<T, D = any, Q = any> = (
  config: ApiFuncData<D, Q>,
) => Promise<ApiResponseSuccess<T>>;

export interface PageData {
  page: number;
  page_size: number;
}

export type ResponseDataWithPager<T> = {
  data: T[];
  pager: {
    CurrentPage: number;
    PerPage: number;
    TotalCount: number;
    TotalPage: number;
  };
};

export type TRequestPagerFunc<T = any> = RequestFunction<ResponseDataWithPager<T>>;

export type NumberAsBoolean = 0 | 1;
